var app = getApp();
Page({
  data: {
    categoryId: '',
    categoryName: '',
    cardNo: '',
    cardPassword: '',
  },
  
  onShow:function(){
    var that = this
    var category = wx.getStorageSync('category');
    that.setData({
      categoryId: category.id,
      categoryName: category.name
    })
  },

  goBind: function (e) {
    var that = this;
    console.log("no="+that.data.cardNo);
    var params = {
      'cardNumber': that.data.cardNo,
      /**'cardPassword': that.data.cardPassword,**/
      'signUserid': wx.getStorageSync('uid'),
      'signSubjectId':that.data.categoryId,
      'signSubjectName':that.data.categoryName,
    }
    if (params.cardNumber == "" || params.cardNumber == "") {
      wx.showToast({
        title: "请填写卡号",
        icon: 'loading',
        duration: 2e3
      })
      return false;
    }
    /** 
    if (params.cardPassword == "" || params.cardPassword == "") {
      wx.showToast({
        title: "请填写密码",
        icon: 'loading',
        duration: 2e3
      })
      return false;
    }
      **/
    wx.request({
      url: app.globalData.url + app.interfaceAddress.activate,
      method: 'post',
      dataType: 'json',
      data: params,
      success: function (res) {
        console.log("res.code="+res.data.code);
        if(res.data.code == 0){
          wx.showModal({
            title: "操作成功",
            content: res.data.msg,
            showCancel: !1,
            confirmText: "去练习",
            confirmColor: "#1c90fa",
            success: function (e) {
              wx.navigateBack();
            }
          });
        }else{
           wx.showModal({
            title: "操作失败",
            content: res.data.msg,
            showCancel: !1,
            confirmText: "好的",
            confirmColor: "#1c90fa",
            success: function (e) {
            }
          });
        }
        
      }
    })
  },
  goquestion: function (t) {
    wx.navigateTo({
      url: "../errorstar/errorstar?ids="+ t.currentTarget.dataset.ids+"&title=题目详情&navtitle=题目详情&cateName=其他" 
    })
  },
});